/* GLOBAL NAV AND FOOTER JS (Older template usage) $Id: //depot/projects/dylan/releases/rc_16_11_1/docroot/js/globalnav.js#1 $ */ // Include JSONP library for community.adobe.com pages, which don't get it loaded as www.adobe.com pages do var adobe_host = window.location.hostname; if (adobe_host == "community.adobe.com") { /* JSON-P implementation for Prototype.js somewhat by Dan Dean (http://www.dandean.com) * * *HEAVILY* based on Tobie Langel's version: http://gist.github.com/145466. * Might as well just call this an iteration. * * This version introduces: * - Support for predefined callbacks (Necessary for OAuth signed requests, by @rboyce) * - Partial integration with Ajax.Responders (Thanks to @sr3d for the kick in this direction) * - Compatibility with Prototype 1.7 (Thanks to @soung3 for the bug report) * - Will not break if page lacks a element * * See examples in README for usage * * VERSION 1.1.2 * * new Ajax.JSONRequest(url, options); * - url (String): JSON-P endpoint url. * - options (Object): Configuration options for the request. */ Ajax.JSONRequest = Class.create(Ajax.Base, (function() { var id = 0, head = document.getElementsByTagName('head')[0] || document.body; return { initialize: function($super, url, options) { $super(options); this.options.url = url; this.options.callbackParamName = this.options.callbackParamName || 'callback'; this.options.timeout = this.options.timeout || 10; // Default timeout: 10 seconds this.options.invokeImmediately = (!Object.isUndefined(this.options.invokeImmediately)) ? this.options.invokeImmediately : true ; if (!Object.isUndefined(this.options.parameters) && Object.isString(this.options.parameters)) { this.options.parameters = this.options.parameters.toQueryParams(); } if (this.options.invokeImmediately) { this.request(); } }, /** * Ajax.JSONRequest#_cleanup() -> undefined * Cleans up after the request **/ _cleanup: function() { if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; } if (this.transport && Object.isElement(this.transport)) { this.transport.remove(); this.transport = null; } }, /** * Ajax.JSONRequest#request() -> undefined * Invokes the JSON-P request lifecycle **/ request: function() { // Define local vars var response = new Ajax.JSONResponse(this); var key = this.options.callbackParamName, name = '_prototypeJSONPCallback_' + (id++), complete = function() { if (Object.isFunction(this.options.onComplete)) { this.options.onComplete.call(this, response); } Ajax.Responders.dispatch('onComplete', this, response); }.bind(this); // If the callback parameter is already defined, use that if (this.options.parameters[key] !== undefined) { name = this.options.parameters[key]; } // Otherwise, add callback as a parameter else { this.options.parameters[key] = name; } // Build request URL this.options.parameters[key] = name; var url = this.options.url + ((this.options.url.include('?') ? '&' : '?') + Object.toQueryString(this.options.parameters)); // Define callback function window[name] = function(json) { this._cleanup(); // Garbage collection window[name] = undefined; response.status = 200; response.statusText = "OK"; response.setResponseContent(json); if (Object.isFunction(this.options.onSuccess)) { this.options.onSuccess.call(this, response); } Ajax.Responders.dispatch('onSuccess', this, response); complete(); }.bind(this); this.transport = new Element('script', { type: 'text/javascript', src: url }); if (Object.isFunction(this.options.onCreate)) { this.options.onCreate.call(this, response); } Ajax.Responders.dispatch('onCreate', this); head.appendChild(this.transport); this.timeout = setTimeout(function() { this._cleanup(); window[name] = Prototype.emptyFunction; if (Object.isFunction(this.options.onFailure)) { response.status = 504; response.statusText = "Gateway Timeout"; this.options.onFailure.call(this, response); } complete(); }.bind(this), this.options.timeout * 1000); }, toString: function() { return "[object Ajax.JSONRequest]"; } }; })()); Ajax.JSONResponse = Class.create({ initialize: function(request) { this.request = request; }, request: undefined, status: 0, statusText: '', responseJSON: undefined, responseText: undefined, setResponseContent: function(json) { this.responseJSON = json; this.responseText = Object.toJSON(json); }, getTransport: function() { if (this.request) return this.request.transport; }, toString: function() { return "[object Ajax.JSONResponse]"; } }); } // Load in the Accessibility JS file off the CDN $$("head")[0].insert(new Element("script", { type: "text/javascript", src: "https://wwwimages2.adobe.com/ubi/template/identity/adobe/GlobalNavAccessibility.js" })); // Set var for Evidon Ad Choices link to show by default var hideEvidon = false; document.observe('dom:loaded', function() { // Set up vars for IMS and signed in state var screenName = $('screenName'); var signOutHREF = null; var IMS_REDIRECT_URI = null; IMS_SCOPE = "AdobeID,openid"; IMS_AUTH_ENDPOINT = null; IMS_LOGOUT_ENDPOINT = null; IMS_LOGOUT_ENDPOINT_REDIRECT = null; IMS_AUTH_CHECK_ENDPOINT = null; IMS_CLIENT_ID = null; // Make sure the screenname HTML element is present on the page if (screenName) { // Check cookie values and assign to vars WCDServerPresent = adobe.Cookie.get('WCDServer'), RengaRMTPresent = adobe.Cookie.get('RengaRMT'), RmPresent = adobe.Cookie.get('rm'), hostIMSValue = adobe.Cookie.get("gnavHostIMS"), hostIDPValue = adobe.Cookie.get("gnavHostIDP"), clientIDValue = adobe.Cookie.get("gnavClientID"); // If IMS cookies were present, set up additional vars with server information if ( (hostIMSValue) && (hostIDPValue) && (clientIDValue) ) { IMS_AUTH_ENDPOINT = "https://" + hostIMSValue + "/authorize"; IMS_LOGOUT_ENDPOINT = "https://" + hostIDPValue + "/ims/logout/v1/token"; IMS_LOGOUT_ENDPOINT_REDIRECT = "https://" + hostIDPValue + "/ims/logout/v1"; IMS_AUTH_CHECK_ENDPOINT = "https://" + hostIDPValue + "/ims/check/v1/token"; IMS_CLIENT_ID = clientIDValue; } // Check to see if the user is likely signed in because they have one of the SSO cookies if ( (WCDServerPresent) || (RengaRMTPresent) || (RmPresent) ) { // Check to see if the IMS information is already set if ( (IMS_AUTH_CHECK_ENDPOINT) && (IMS_CLIENT_ID) ) { // Since we have the IMS server information, get the user's information gnavGetUserName(); } else { // Get the IMS server information gnavGetIMSInfo(); } } else { // Since the cookies were not found, do a check over HTTPS to see if the cookie was set as secure gnavGetSecureCookies(); } } // Use secure Akamai-hosted service to check to see if user has one of the SSO cookies function gnavGetSecureCookies() { // Set a variable with a "random" number var randNum = new Date().getTime(); // Make the Ajax call to the Akamai-hosted service, passing the cacheblock parameter to keep it from being // cached by some browsers new Ajax.JSONRequest ("https://verify.adobe.com/ssocheck/", { callbackParamName: "callback", parameters: { format: 'json', callback: 'parseSSOData', cacheblock: randNum }, onSuccess: function(response) { // Check JSON reply if ("hasSSOCookie" in response.responseJSON) { hasSSOCookieValue = response.responseJSON['hasSSOCookie']; // Check to see if user had a secure SSO cookie if (hasSSOCookieValue == true) { // If we have IMS server information, get the user's information, otherwise, get IMS server information if ( (IMS_AUTH_CHECK_ENDPOINT) && (IMS_CLIENT_ID) ) { gnavGetUserName(); } else { gnavGetIMSInfo(); } } } } }); } // Get the IMS server information from the configuration service function gnavGetIMSInfo() { var adobe_host = window.location.hostname, confURL = "https://www.adobe.com/svcs/configurations/clients/adobedotcomIMS/client_aliases/adobedotcom?landscape=" + adobe_host; // Use local configuration service for internal stage/qa/dev environments if ( (adobe_host.include('stage')) || (adobe_host.include('dev')) || (adobe_host.include('qa')) ) { var confURL = "/svcs/configurations/clients/adobedotcomIMS/client_aliases/adobedotcom?landscape=" + adobe_host; } new Ajax.JSONRequest (confURL, { callbackParamName: "callback", parameters: { format: 'json' }, onSuccess: function(response) { // Check JSON reply if (response.responseJSON.configurations.clients[0].client_aliases.properties) { var properties = {}, result = {}, propertiesRoot = response.responseJSON.configurations.clients[0].client_aliases.properties; for (var i = 0; i < propertiesRoot.length; i++) { properties[propertiesRoot[i].key] = propertiesRoot[i].value; } result.attributes = properties; // If proper values are returned, set up vars and set cookies for the session if ( (result.attributes.imsHost) && (result.attributes.idpHost) && (result.attributes.actualClient) ) { adobe.Cookie.set('gnavHostIMS', result.attributes.imsHost, 0, '/', '.adobe.com'); adobe.Cookie.set('gnavHostIDP', result.attributes.idpHost, 0, '/', '.adobe.com'); adobe.Cookie.set('gnavClientID', result.attributes.actualClient, 0, '/', '.adobe.com'); IMS_AUTH_ENDPOINT = "https://" + result.attributes.imsHost + "/authorize"; IMS_LOGOUT_ENDPOINT = "https://" + result.attributes.idpHost + "/ims/logout/v1/token"; IMS_LOGOUT_ENDPOINT_REDIRECT = "https://" + result.attributes.idpHost + "/ims/logout/v1"; IMS_AUTH_CHECK_ENDPOINT = "https://" + result.attributes.idpHost + "/ims/check/v1/token"; IMS_CLIENT_ID = result.attributes.actualClient; // Get the user's information gnavGetUserName(); } } } }); } // Get user information from IMS function gnavGetUserName() { new Ajax.JSONRequest (IMS_AUTH_CHECK_ENDPOINT, { callbackParamName: "callback", parameters: { client_id: IMS_CLIENT_ID, scope: IMS_SCOPE, format: 'json' }, onSuccess: function(response) { // Handle signed in state on standard global nav if ($('shWelcome') !== null) { // Continue if correct data record is retrieved if ("displayName" in response.responseJSON) { // Put user name in HTML element screenNameValue = response.responseJSON['displayName']; screenName.innerHTML = screenNameValue; // Swap elements to show signed in state $('shWelcome').show(); $('shSignInBlock').hide(); } else { // Swap elements to show signed out state $('shWelcome').hide(); $('shSignInBlock').show(); } } } }); } }); Event.observe(window, 'load', function() { // Rewrite Sign in link with an encoded Return URL appended if there is a standard global nav Sign in link // on the page var signInHREF; var signInElementRef; // If SignInPanel is null, we are in the regular signin flow needing a return url and a separate my adobe link, else we are in the new "sign in to my adobe" flow which leads to the account.html page without any return url and a hidden my adobe link as the SignInPanel will have that. if($('shSignIn') !== null && $('SignInPanel')==null){ signInElementRef=$('shSignIn'); signInHREF= $('shSignIn').readAttribute('href'); if (signInHREF.include('?')) { signInHREF = signInHREF + "&returnURL=" + encodeURIComponent(window.location.href); } else { signInHREF = signInHREF + "?returnURL=" + encodeURIComponent(window.location.href); } signInElementRef.writeAttribute('href', signInHREF); if($('shMyAdobe') !== null) $("shMyAdobe").show(); } if($('shSignIn') !== null && $('SignInPanel')!==null){ if($('shMyAdobe') !== null) $("shMyAdobe").hide(); } // Fill in the Search box with localized "Search" text if ($('search-input') !== null) { adobe.InputTitleOverlay.init("search-input"); } // Event handler for Sign out link on pages with the standard global nav to use IMS servers by default and fall // back to CF app if needed if ($('shSignOutLink') !== null) { // Get the Sign out link value signOutHREF = $('shSignOutLink').readAttribute('href'); // Get rid of the HREF for the Sign out link and add a click handler to trigger instead // (This gets around the fact that the Prototype 1.6.0.2 event stop handler does not work with IE 9 and IE 10) $('shSignOutLink').removeAttribute( "href" ); $('shSignOutLink').setStyle({cursor:"pointer"}); $('shSignOutLink').observe('click', function(event) { // Contact the IMS server to sign the user out if we have the IMS server information if ( (IMS_LOGOUT_ENDPOINT) && (IMS_CLIENT_ID) && (IMS_SCOPE) ) { new Ajax.JSONRequest (IMS_LOGOUT_ENDPOINT, { callbackParamName: "callback", parameters: { client_id: IMS_CLIENT_ID, scope: IMS_SCOPE, format: 'json' }, onComplete: function(response) { // SiteCatalyst tracking if (window.s_adobe_account) { s_adobe=s_gi(window.s_adobe_account); s_adobe.linkTrackVars="prop17"; s_adobe.prop17="cc_NotSignedIn"; s_adobe.tl(this,'o','adobe.com:GlobalNav:SignOut'); } // Expire these Dylan membership cookies so CF apps (like Entitlement) don't think the user is still // signed in adobe.Cookie.set('AUID', '', -1, '/', '.adobe.com'); adobe.Cookie.set('SCREENNAME', '', -1, '/', '.adobe.com'); // Swap elements to show signed out state $('shWelcome').hide(); $('shSignInBlock').show(); // Get the URL of the page the user is on so we can check if it is a CF app var checkURL = window.location.pathname; // If it is a CF app, give SiteCatalyst code a second to do its thing, then reload the page to clear // out any personal information displayed on the screen if (checkURL.startsWith('/cfusion')) { setTimeout('window.location = window.location.href', 1000); } } }); } else { // SiteCatalyst tracking if (window.s_adobe_account) { s_adobe=s_gi(window.s_adobe_account); s_adobe.linkTrackVars="prop17"; s_adobe.prop17="cc_NotSignedIn"; s_adobe.tl(this,'o','adobe.com:GlobalNav:SignOut'); } // Give SiteCatalyst code a second to do its thing, then redirect the user to the CF app sign out if (signOutHREF.startsWith('http')) { setTimeout('window.location = "http://www.adobe.com/cfusion/membership/logout.cfm?returnURL=" + encodeURIComponent(window.location.href)', 1000); } else { setTimeout('window.location = "/cfusion/membership/logout.cfm?returnURL=" + encodeURIComponent(window.location.href)', 1000); } } }); } // Event handler for Sign out link on entitlement apps without the standard global nav to use IMS servers by // default and fall back to CF app if needed // (This should not be in the global nav JS since this is not related to the global nav but to app-specific Sign // out links) if ($('signout') !== null && $('signout').firstChild !== null) { // Get the current Sign out link URL IMS_REDIRECT_URI = $('signout').childElements()[0].readAttribute('href'); // If the current Sign out link URL is relative, add the protocol and domain to it since the IMS page requires // the parameter to be fully qualified if (!IMS_REDIRECT_URI.startsWith('http')) { IMS_REDIRECT_URI = location.protocol + "//" + location.host + IMS_REDIRECT_URI; } IMS_REDIRECT_URI = encodeURIComponent(IMS_REDIRECT_URI); // Get rid of the HREF and add an onclick handler to trigger instead // (This gets around the fact that the Prototype 1.6.0.2 event stop handler does not work with IE 9 and IE 10) $('signout').childElements()[0].removeAttribute( "href" ); $('signout').childElements()[0].setStyle({cursor:"pointer"}); $('signout').childElements()[0].observe('click', function(event) { // SiteCatalyst tracking if (window.s_adobe_account) { s_adobe=s_gi(window.s_adobe_account); s_adobe.linkTrackVars="prop17"; s_adobe.prop17="cc_NotSignedIn"; s_adobe.tl(this,'o','adobe.com:GlobalNav:SignOut'); } // Give SiteCatalyst code a second to do its thing, then redirect the user to the IMS logout workflow with the // app's original Sign out URL as the redirect URL window.setTimeout( function(){ // Contact the IMS server to sign the user out if we have the IMS server information, otherwise go to the // default sign out link destination if ( (IMS_LOGOUT_ENDPOINT_REDIRECT) && (IMS_CLIENT_ID) && (IMS_REDIRECT_URI) ) { window.location = IMS_LOGOUT_ENDPOINT_REDIRECT + "?redirect_uri=" + IMS_REDIRECT_URI + "&client_id=" + IMS_CLIENT_ID + "&access_token=LEAPSIGNOUTTOKEN"; } else { window.location = IMS_REDIRECT_URI; } }, 1000 ); }); } // Handle same height border on global nav dropdowns to meet Design spec function equalizeHeights(divsToSize) { tallestDivHeight = 0; divsToSize.each(function(myDivs) { divHeight = myDivs.getHeight(); if (divHeight > tallestDivHeight) { tallestDivHeight = divHeight; } }); divsToSize.invoke('setStyle', { height: tallestDivHeight + "px" }); } equalizeHeights($$("div.SiteHeaderShadowLeft")); // Check if footer is on the page if ($('SiteFooter')) { // Set RegionPanel var var rp = $('RegionPanel'); // Check to see if the international cookie is set, and if so, set the value to a var var countryCode = adobe.Cookie.get("international"); // If the user has an international cookie set, change Region Panel link if (countryCode) { $('sfRegionSet').show(); $('sfRegion').hide(); } // Capture clicks and show/hide the Region Panel as needed Event.observe(document, 'click', function(event) { var el = event.element(); var elid = el.id; if (elid == "sfRegion" || elid == "sfRegionChange" || elid == "sfRegionClose") { Event.stop(event); $('RegionPanel').toggle(); } else if ((el == rp) || (el.descendantOf(rp))) { if (!el.descendantOf(rp)) { Event.stop(event); } } else { $('RegionPanel').hide(); } }); } /* Evidon ad icon JS */ if (($('_bapw-link') != null) && (hideEvidon != true)) { $('_bapw-link').show(); (function () { var search_param = document.URL.toQueryParams().loc, community_param = document.URL.toQueryParams().hl; if ((adobe.URLParser.host == "www.adobe.com") || (adobe.URLParser.host == "adobe.com") || (adobe.URLParser.host == "get.adobe.com") || (adobe.URLParser.host == "get2.adobe.com") || (adobe.URLParser.host == "get3.adobe.com") || (adobe.URLParser.host == "kb2.adobe.com") || (adobe.URLParser.host == "community.adobe.com") || (adobe.URLParser.host == "helpx.adobe.com") || (adobe.URLParser.host == "store1.adobe.com") || (adobe.URLParser.host == "store2.adobe.com") || (adobe.URLParser.host == "store3.adobe.com")) { if ( (adobe.URLParser.locale == "de") || (search_param == "de") || (community_param == "de") ) { page_id = "322"; } else if ( (adobe.URLParser.locale == "fr") || (search_param == "fr_fr") || (community_param == "fr_fr") ) { page_id = "324"; } else if ( (adobe.URLParser.locale == "uk") || (search_param == "en_gb") || (community_param == "en_gb") ) { page_id = "323"; } else if ( (adobe.URLParser.locale == "se") || (search_param == "sv_SE") || (community_param == "sv") ) { page_id = "1013"; } else if ( (adobe.URLParser.locale == "at") || (search_param == "at") || (community_param == "de_at") ) { page_id = "1012"; } else if ( (adobe.URLParser.locale == "ch_de") || (search_param == "ch_de") || (community_param == "de_ch") ) { page_id = "1010"; } else if ( (adobe.URLParser.locale == "ch_fr") || (search_param == "ch_fr") || (community_param == "fr_ch") ) { page_id = "1009"; } else if ( (adobe.URLParser.locale == "ch_it") || (search_param == "ch_it") || (community_param == "it_ch") ) { page_id = "1011"; } else { page_id = "86"; } } else { if ( (adobe.URLParser.locale == "de") || (search_param == "de") || (community_param == "de") ) { page_id = "327"; } else if ( (adobe.URLParser.locale == "fr") || (search_param == "fr_fr") || (community_param == "fr_fr") ) { page_id = "326"; } else if ( (adobe.URLParser.locale == "uk") || (search_param == "en_gb") || (community_param == "en_gb") ) { page_id = "328"; } else if ( (adobe.URLParser.locale == "se") || (search_param == "sv_SE") || (community_param == "sv") ) { page_id = "1024"; } else if ( (adobe.URLParser.locale == "at") || (search_param == "at") || (community_param == "de_at") ) { page_id = "1021"; } else if ( (adobe.URLParser.locale == "ch_de") || (search_param == "ch_de") || (community_param == "de_ch") ) { page_id = "1020"; } else if ( (adobe.URLParser.locale == "ch_fr") || (search_param == "ch_fr") || (community_param == "fr_ch") ) { page_id = "1022"; } else if ( (adobe.URLParser.locale == "ch_it") || (search_param == "ch_it") || (community_param == "it_ch") ) { page_id = "1023"; } else { page_id = "126"; } } var d = document, pixel, URL_SCHEME = (d.location.protocol == 'https:' ? 'https' : 'http'), CDN_URL = (URL_SCHEME == 'https' ? 'https://info.evidon.com/c/betrad/pub/' : 'http://cdn.betrad.com/pub/'); d.getElementById('_bapw-link').onclick = function () { var link = this; function appendScript(url, callback) { var head = d.getElementsByTagName('head')[0] || d.documentElement, loaded = false, script = d.createElement('script'); function onload() { script.onload = script.onreadystatechange = null; head.removeChild(script); callback(); } script.src = url; script.onreadystatechange = function () { if (!loaded && (this.readyState == 'loaded' || this.readyState == 'complete')) { loaded = true; onload(); } }; script.onload = onload; head.insertBefore(script, head.firstChild); } this.onclick = 'return false'; appendScript(URL_SCHEME+'://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', function () { appendScript(CDN_URL+'pub1.js', function () { BAPW.i(link, { pid: page_id, ocid: 414 }, false); }); }); return false; }; pixel = d.createElement('img'); pixel.src = URL_SCHEME+'://l.betrad.com/pub/p.gif?pid='+page_id+'&ocid='+'414'+'&ii=1&r='+Math.random(); pixel.height = '1'; pixel.width = '1'; pixel.className = 'SiteFooterEvidonPixel'; d.body.appendChild(pixel); }()); } }); // Function for changing the region via the Region Panel function changeRegion(regioncode) { // Handle special cases of cookie value settings and set cookies for 1 year expiration if (regioncode.startsWith('be_')) { adobe.Cookie.set('international', regioncode, 365, '/', '.adobe.com'); adobe.Cookie.set('storeregion', 'be', 365, '/', '.adobe.com'); } else if (regioncode.startsWith('ca')) { adobe.Cookie.set('international', regioncode, 365, '/', '.adobe.com'); adobe.Cookie.set('storeregion', 'ca', 365, '/', '.adobe.com'); } else if (regioncode.startsWith('eeur')) { adobe.Cookie.set('international', regioncode, 365, '/', '.adobe.com'); adobe.Cookie.set('storeregion', 'eu', 365, '/', '.adobe.com'); } else if (regioncode.startsWith('hk_')) { adobe.Cookie.set('international', regioncode, 365, '/', '.adobe.com'); adobe.Cookie.set('storeregion', 'cn', 365, '/', '.adobe.com'); } else if (regioncode.startsWith('lu_')) { adobe.Cookie.set('international', regioncode, 365, '/', '.adobe.com'); adobe.Cookie.set('storeregion', 'lu', 365, '/', '.adobe.com'); } else if (regioncode.startsWith('uk')) { adobe.Cookie.set('international', regioncode, 365, '/', '.adobe.com'); adobe.Cookie.set('storeregion', 'gb', 365, '/', '.adobe.com'); } else { adobe.Cookie.set('international', regioncode, 365, '/', '.adobe.com'); adobe.Cookie.set('storeregion', regioncode, 365, '/', '.adobe.com'); } // Get the page the user is on var currURL = window.location.pathname + window.location.search; // Check to see if the user is already on a GEO (non-US) site var geoArray = ["africa","ap","at","au","be_en","be_fr","be_nl","bg","br","ca","ca_fr","ch_de","ch_fr","ch_it","cn","cz","de","dk","eeurope","ee","es","fi","fr","hk_en","hk_zh","hr","hu","ie","il_en","in","it","jp","kr","la","lt","lu_de","lu_en","lu_fr","lv","mena_en","mena_fr","mx","nl","no","nz","pl","pt","ro","rs","ru","si","se","sea","sk","tr","tw","ua","uk"]; geoArray.each(function(item) { // If the user is on a GEO site, remove the location value from the path if (currURL.startsWith('/'+item+'/')) { currURL = currURL.replace('/'+item+'/','/'); throw $break; } }); // Build the URLs to redirect the user to: // newURL = the URL of the page the user is on in the region they selected // homeURL = the URL of the homepage in the region they selected // If the user is in a CF app and in the US site, set both URLs to the US homepage if ((currURL.startsWith('/cfusion')) && (regioncode == 'us')) { newURL = "/"; homeURL = "/"; } // If the user is in a CF app and in a GEO (non-US) site, set both URLs to the respective region's homepage else if ((currURL.startsWith('/cfusion')) && (regioncode != 'us')) { newURL = "/" + regioncode + "/"; homeURL = "/" + regioncode + "/"; } // If the user selected a GEO (non-US) site, set the URLs to the respective region's version of the page and the respective region's homepage else if (regioncode != 'us') { newURL = "/" + regioncode + currURL; homeURL = "/" + regioncode + "/"; } // If the user select the US site, set the URLs to the US version of the page and the US homepage else { newURL = currURL; homeURL = "/"; } // Check to see if the page we want to send the user to actually exists, and if not, go to the homepage instead new Ajax.Request(newURL, { method: 'get', onSuccess: function(response) { window.location = newURL; }, onFailure: function(response) { window.location = homeURL; } }); }